import java.io.UnsupportedEncodingException;

/**
 * @author wei kunJie
 * @date 2024/4/21 13:59:59
 */
public class Main {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String str = "你好Hello你好Hello你好Hello你好Hello你好Hello你好Hello你好Hello你好Hello你好Hello";
        byte[] bytes = str.getBytes(); // 将字符串转换为字节数组

        int segmentSize = 1024; // 每个分段的字节数
        int totalSegments = (int) Math.ceil((double) bytes.length / segmentSize); // 计算总共的分段数

        // 分段输出
        for (int i = 0; i < totalSegments; i++) {
            int startIndex = i * segmentSize;
            int endIndex = Math.min(startIndex + segmentSize, bytes.length);
            String segment = new String(bytes, startIndex, endIndex - startIndex);
            System.out.println("Segment " + (i + 1) + ": " + segment);
        }
    }
}
